<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<link rel="stylesheet" href="${staticServer}/inc/style/main.css"/>
	<link rel="stylesheet" href="${staticServer}/inc/style/page.css"/>
	<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css"/>
	<link rel="stylesheet" href="${staticServer}/css/consultant_client.css"/>
	<link rel="stylesheet" href="${staticServer}/css/consultant_client_reserve.css"/>
	<script src="${staticServer}/inc/js/jquery.js"></script>
	<script src="${staticServer}/inc/js/pageset.js"></script>
	<script src="${staticServer}/inc/js/datepicker.js"></script>
	<script src="${staticServer}/js/web/system_reserve_stat.js?3.2"></script>
    <script src="${staticServer}/js/web/echarts.js"></script>
    <script src="${staticServer}/js/web/esl.js"></script>
	<script>

	function dataChange( v )
	{
		location.href = url_param( location.href, { start_date: v } );
	}
	</script>
	<style type="text/css">
		#reservelst td {
			color: #999;
			font-size: 12px;
		}
	</style>
	<script>
		$(function(){
			getFollow();
			$("#zonji1").html($("#center1 td").find("a").length);
			$("#zonji2").html($("#center2").find("a").length);
			$("#zonji3").html($("#center3").find("br").length);
			$("#zonji4").html($("#center4").find("br").length);
			$("#zonji5").html($("#center5").find("br").length);
			$("#zonji6").html($("#center6").find("br").length);
		});

		var getFollow = function(){
			var date = $("#start_date").val();
			$.post("${contextPath}/index/get_center_reserve.json", {
				"date":date
			}, function(ms) {
				var list = ms.list;
				var count = 0;
				for(var i=0;i<list.length;i++){
					var re = new RegExp("-", "g");
					var ids = (list[i].dates).replace(re,"")+list[i].region;
					var objHtml =list.length+'<br/>';
				}
			});
		}
		
		$(document).ready(function(){
			var a = $("#weekrow").find("th").length;
			var i=$('div').size();//获得div标签的数目
			var j=$('.ff').size();//获得class为ff的font标签的数目
		})
	</script>
    <script>
        function getCore() {
            var cityName = $('select option:selected').val();
            $.ajax({
                type: 'POST',
                url: 'system_getcorename.htm',
                data: {"cityName": cityName},
                dataType: "json",
                success: function (data) {
                    $("#coreName").empty(); //清除select
                    $.each(data, function (index, values) { // 解析出data对应的Object数组
                        $("#coreName").append("<option value='" + values.keyname + "'>" + values.name + "</option>");
                    });
                },
                error: function () {
                    alert("系统出现问题");
                }
            });
        }
    </script>
    <script>
        var myChart;
        function selectWeek(){
            var cityName =  $("#cityName").val();
            var keyname =  $("#coreName").val();
            var coreName = $('#coreName option:selected').text();//选中的文本
            var date =  $("#start_date2").val();
            if (cityName==null||cityName==""){
                alert("请选择城市!")
            }else if (coreName==null){
                alert("请选择中心!")
            }else if (date==""){
                alert("请选择截止日期!")
            }else {
                myChart.showLoading({
                    text: "图表数据正在努力加载..."
                });
                $.ajax({
                    type: 'POST',
                    url: 'system_select_24week.htm',
                    data: {"cityName": cityName,"keyname":keyname,"date":date},
                    dataType: "json",
                    success: function (data) {
                        var nationalRate = [${nationalRate}];
                        var nationalNotRate = [${nationalNotRate}];
                        $.each(data, function (index, values) { // 解析出data对应的Object数组
                            var   cityRate =values.cityRate;
                            var   cityNotRate =values.cityNotRate;
                            var   coreRate = values.coreRate;
                            var   corenotRate = values.corenotRate;
                            var week = values.week;
                            cityRate = cityRate.split(",");
                            cityNotRate = cityNotRate.split(",");
                            coreRate = coreRate.split(",");
                            corenotRate = corenotRate.split(",");
                            week = week.split(",");
                            myCharts(cityName,coreName,week,nationalRate,nationalNotRate,cityRate,cityNotRate,coreRate,corenotRate);
                        });
                    },
                    error: function () {
                        alert("系统出现问题!");
                    }
                });



            }return false;
        }

        function  myCharts(cityName,coreName,week,nationalRate,nationalNotRate,cityRate,cityNotRate,coreRate,corenotRate){
            require.config({
                paths:{
                    'echarts' : 'http://echarts.baidu.com/build/echarts',
                    'echarts/chart/bar' : 'http://echarts.baidu.com/build/echarts'
                }
            });
            // 周统计
            require(
                    [
                        'echarts',
                        'echarts/chart/line' // 使用柱状图就加载bar模块，按需加载
                    ],
                    function (ec) {
                        // 基于准备好的dom，初始化echarts图表
                         myChart = ec.init(document.getElementById('week'));
                        var option = {
                            tooltip: {
                                show: true
                            },
                            legend: {
                                data:['全国平均到访率','全国平均未到率',cityName+"平均到访",cityName+"平均未到率",
                                coreName+"平均到访率",coreName+"平均未到率"
                                ]
                            },
                            toolbox: {
                                show : true,
                                feature : {
                                    mark : {show: true},
                                    dataView : {readOnly:false},
                                    magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                                    restore : {show: true},
                                    saveAsImage : {show: true}
                                }
                            },   calculable : true,
                            dataZoom : {
                                show : true,
                                realtime : true,

                            },
                            xAxis : [
                                {
                                    type : 'category',
                                    data : week

                                }
                            ],
                            yAxis : [
                                {
                                    type : 'value'
                                }
                            ],
                            series : [
                                {
                                    "name":"全国平均到访率",
                                    "type":"line",
                                    "data":nationalRate
                                },
                                {
                                    "name":"全国平均未到率",
                                    "type":"line",
                                    "data":nationalNotRate
                                },
                                {
                                    "name":cityName+"平均到访",
                                    "type":"line",
                                    "data":cityRate
                                },
                                {
                                    "name":  cityName+"平均未到率",
                                    "type":"line",
                                    "data":cityNotRate
                                },
                                {
                                    "name": coreName+"平均到访率",
                                    "type":"line",
                                    "data":coreRate
                                },
                                {
                                    "name": coreName+"平均未到率",
                                    "type":"line",
                                    "data":corenotRate
                                }

                            ]
                        };
                        myChart.hideLoading();
                        // 为echarts对象加载数据
                        myChart.setOption(option);
                    }
            );

        }

    </script>



</head>

<body>
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>资源统计管理</li>
			<li>&gt;</li>
			<li class="current">中心到访统计</li>
		</ul>
	</div>
	<div id="container">
		<div id="title"></div>
		<table class="form_table">
			<tr>
				<td><label><b>查询条件：</b></label> <label for="start_date">统计日期：</label>
					<input type="text" id="start_date" size="15" value="${newday}" rel="DATE::Y-m-d;dataChange"/>
					<input type="button" value=" 刷新 " onclick="cdatetime(2)" />
	               <#-- <input type="button" value=" 上一周 " onclick="cdatetime(-1)" />
	                <input type="button" value=" 下一周 " onclick="cdatetime(1)" />
	                <input type="button" value=" 最近一周 " onclick="cdatetime(0)" />-->
				</td>
			</tr>
		</table>
		<table id="reservelst">
			<tbody>
			<tr id="weekrow" class="even_row">
				<th width="150"></th>
				<th class="week">全年平均到访率</th>
				<th class="week">全年未到率</th>
				<th class="week">半年平均到访率</th>
				<th class="week">半年未到率</th>
				<th class="week">上月到访率</th>
				<th class="week">上月未到率</th>
				<th class="week">上周到访率</th>
				<th class="week">上周未到率</th>
			<#--	<th style="text-align: center;">实到</th>
				<th style="text-align: center;">未到</th>
				<th style="text-align: center;">未到率</th>-->
			</tr>
			<#if office_List??>
			<#list office_List as list>
				<#if list.keyname!="CCEE06DEB51D">
					<tr class="odd_row" id="center${list_index?if_exists+1}">
						<th rel="${list.keyname}" title="${list.name}" class="time">${list.name}</th>
						<#if list.cout2??>
						<#list list.cout2 as clist>
						<#if clist_index == 0>
						<td align="center" id="">${clist.count}</td>
						</#if>
						<#if clist_index == 1>
						<td align="center" id=" ">${clist.count}</td>
						</#if>
						<#if clist_index == 2>
						<td align="center" id="">${clist.count}</td>
						</#if>
						<#if clist_index == 3>
						<td align="center" id="">${clist.count}</td>
						</#if>
						<#if clist_index == 4>
						<td align="center" id="">${clist.count}</td>
						</#if>
						<#if clist_index == 5>
						<td align="center" id="">${clist.count}</td>
						</#if>
						<#if clist_index == 6>
						<td align="center" id="">${clist.count}</td>
						</#if>
						<#if clist_index == 7>
                         <td align="center" id="">${clist.count}</td>
						</#if>
						</#list>
						</#if>
						<#--<td align="center" id="zonji" >${list.total_reserve}</td>
						<td align="center">${list.real_visit}</td>
						<td align="center">${list.not_visit}</td>
						<#if list.rate!=''>
						<td align="center">${list.rate}</td>
						<#else>
						<td align="center">0%</td>
						</#if>-->
					</tr>
				</#if>
			</#list>
			</#if>
			<#--<tr class="odd_row" id="center11111">
				<th rel="" title="" class="time">总计</th>
					<td align='center' colspan='7'>
					<td align="center" id="zonji" >${total}</td>
					<td align="center">${real}</td>
					<td align="center">${not}</td>
					<#if totrate!=''>
					<td align="center">${totrate}</td>
					<#else>
					<td align="center">0%</td>
					</#if>
				</th>
			</tr>-->
			</tbody>
		</table>
	</div>

<div id="pager" style="width: 820px;">
	<ul id="pagination">
		<#if page??>
		<#if page.pagetotal?? && page.pagetotal!="0">
	<#assign pagetotal = page.pagetotal>
	<#else>
	<#assign pagetotal = 1>
	</#if>
			<#if page.currpage??>
	<#assign currpage = page.currpage>
	<#else>
	<#assign currpage = 1>
	</#if>
				<#if currpage==1 >
					<li class="previous-off">上一页</li>
					<#else>
					<li class="previous"><a href="${contextPath}/index/system_center_stat.htm?currPage=${currpage-1}">上一页</a></li>
					</#if>
					
		<#if pagetotal<=11>
			<#list 1..pagetotal as index_up>  
	           <#if currpage==index_up > 
	           		<li class="current">${index_up}</li>
	           <#else>
	           		<li><a href="${contextPath}/index/system_center_stat.htm?currPage=${index_up}">${index_up}</a></li>  
	           </#if>  
			</#list>  
		<#else>
			<#if currpage<=8 >
				<#list 1..9 as index_up>  
	           	<#if currpage==index_up >  
	            	<li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/system_center_stat.htm?currPage=${index_up}">${index_up}</a></li> 
	           	</#if>
	           	</#list>  
	           	<li>...</li>
	           	<li><a href="${contextPath}/index/system_center_stat.htm?currPage=${pagetotal}">${pagetotal}</a></li>  
				
			<#elseif (currpage>= 9 && currpage<pagetotal-7)  >	
				<li><a href="${contextPath}/index/system_center_stat.htm?currPage=1">1</a></li>  
				<li>...</li>
				<#list currpage-3..currpage+3 as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/system_center_stat.htm?currPage=${index_up}">${index_up}</a></li>  
	           	</#if>
	           	</#list>
				<li>...</li>
	           	<li><a href="${contextPath}/index/system_center_stat.htm?currPage=${pagetotal}">${pagetotal}</a></li>   
			<#else>
				<li><a href="${contextPath}/index/system_center_stat.htm?currPage=1">1</a></li> 
				<li>...</li>
				<#list pagetotal-8..pagetotal as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/system_center_stat.htm?currPage=${index_up}">${index_up}</a></li> 
	           	</#if>
				</#list>  
			</#if>
			
		</#if> 
		<#if currpage==pagetotal >
		 	<li class="previous-off">下一页</li>
		<#else>
			<li class="previous"><a href="${contextPath}/index/system_center_stat.htm?currPage=${currpage+1}">下一页</a></li>
		</#if>
		<li class="pageinfo">共${page.total}条记录</li>
	</#if>
	</ul>
	</div>
	<div class="emptyline clear"></div>
	
	
	<table  align="center" class="form_table" border="0">
        <tr style="text-align:center">
            <td>
                截止时间:
            </td>
			<td>
                <input type="text" id="start_date2" size="15" value="${newday2}" rel="DATE::Y-m-d"/>
            </td>


            <td style="text-align:center">
				<select id="cityName" onchange="getCore()">
                    <option value="">--请选择城市--</option>
				<#list citySet as city>
                <option value="${city}">${city}</option>
				</#list>
                    </select>
			</td>
            <td style="text-align:center">
                <select id="coreName">

                </select>
            </td>
			<td><input type="button" value=" 查询 " onclick="selectWeek()" /></td>
        </tr>

    </table>

    <table>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;周统计：
        <tr>
             <div id="week" style="height:400px"></div>
        </tr>

    </table>

    </div>


</body>

<script>
    var selectMsg = function(){
        var startTime = $("#start_date").val();
        window.location.href=encodeURI("${contextPath}/index/system_center_zhuzhuang.htm?startTime="+startTime);
    }
    var week = [${weekDate}];
    var nationalRate = [${nationalRate}];
    var nationalNotRate = [${nationalNotRate}];

    myCharts("城市","中心",week,nationalRate,nationalNotRate,"","","","");
</script>

</body>
</html>